#!/bin/bash

source /etc/profile
start(){
    nohup java -jar -Xmx1536m -Xms512m -XX:+UseG1GC *.jar 2>&1 & echo $! > service.pid
}

stop(){
    pid=`cat service.pid`
    if [ -z $pid ]
    then 
        echo "pid"
    else
        kill -9 ${pid}
        kill -9 ${pid}
        kill -9 ${pid}
    fi
}

case $1 in
start)
    start
    ;;
stop)
    stop
    ;;
    
restart)
    stop
    sleep 5
    start
    ;;
*)
    echo "[start|stop|restart]"
    ;;
    
esac
